package com.gzz.orchid.common.boot.mybatis.conditices;

import java.math.BigDecimal;
import java.util.Set;
import java.util.stream.Collectors;

/**
 * @author higmd
 */
public class DemoExec {
    public static void main(String[] args) {
        String[] str = new String[]{"张三", "王五", "赵六"};
        Object[] obj = new Object[]{16456, 2342,5233, 2345, 2345, 2345, 2345, 2345, 2345, 2345, 2345, 2345, 2345, 2345, 2345, 2345, 2345, 2345, 2345, 2345, 2345, 2345, 2345, 2345, 2345, 2345,};

        //
        QueryCondition queryCondition = new QueryCondition();
        queryCondition.eq( "name", "张三")
                .eq("sex", "男")
                .or()
                .gt("a.age", new BigDecimal("23"))
                .or(item->{
                    item.eq("sex", "男")
                            .lt("phone", "12345678901")
                            .like("good", "wr33");
                })
                .like("name" , "wgekn")
                .and(item->{
                    item.eq("sex", "女")
                            .or()
                            .gt("phone", "12345678901");
                })
                .between("birthday", "2020-01-01", "2020-12-31")
                .in("phone", str)
        ;
        var expression = queryCondition.resolveExpression();
        System.out.println("SQL = " + expression);
        Set<String> set = Set.of("name", "sex", "phone", "birthday");
        var sql = set.stream().map(item -> {
            return String.format("%s = %s", item, "?");
        }).collect(Collectors.joining(","));
        System.out.println("sql = " + sql);
    }

}
